import request from "@/utils/request";

//查询物料列表
export function mdItemList(query) {
  return request({
    url: "/mes/md/mditem/list/qc",
    method: "get",
    params: query,
  });
}
export function listMdItem(query) {
  return request({
    url: "/mes/pro/routeproductbom/selectRouteBOMlist",
    method: "get",
    params: query,
  });
}
// 查询物料详细
export function getMdItem(itemId) {
  return request({
    url: "/mes/md/mditem/" + itemId,
    method: "get",
  });
}

// 新增物料
export function addMdItem(data) {
  return request({
    url: "/mes/md/mditem",
    method: "post",
    data: data,
  });
}

// 修改物料
export function updateMdItem(data) {
  return request({
    url: "/mes/md/mditem",
    method: "put",
    data: data,
  });
}

// 删除物料
export function delMdItem(itemId) {
  return request({
    url: "/mes/md/mditem/" + itemId,
    method: "delete",
  });
}

//同步
// export function synchronousData(query) {
//   return request({
//     url: "/mes/k3cloud/api/material/syncMaterialList",
//     method: "get",
//     params: query,
//   });
// }

export function synchronousData(query) {
  return request({
    url: "/sync/k3cloud/api/mdItemSync/mdItemSync",
    method: "get",
    params: query,
  });
}

//附件下载
export function attachmentDownLoad(id) {
  return request({
    url: "/mes/k3cloud/api/material/attachmentDownLoad/" + id,
    method: "post",
    responseType: "blob",
  });
}
// export function attachmentDownLoad(id) {
//   return request({
//     url: '/mes/k3cloud/api/material/preview/'+ id,
//     method: 'get',
//     responseType: 'blob'
//   })
// }
//文件预览
export function attachmentPreview(id) {
  return request({
    url: "/mes/k3cloud/api/material/preview/" + id,
    method: "get",
  });
}

// 设置关键器件
export function itemkeySet(data) {
  return request({
    url: "/mes/wm/itemrecptline/itemkeySet",
    method: "post",
    data: data,
  });
}
//解绑
export function deleteKeyItem(itemCode) {
  return request({
    url: "/mes/wm/warehouse/inventory/" + itemCode,
    method: "delete",
  });
}
